import java.io.File;

public class DeleteDirDemo01 {
    public static void main(String[] args) {
        String path = "C:\\Users\\Administrator\\Desktop\\1";
        delete(new File(path));
    }


    public static void delete(File file) {
        File[] files = file.listFiles();//[1.txt,2]  [3.txt,3] [1.txt]
        for (File f : files) {
            if (f.isDirectory()) {
                delete(f);
                f.delete();
            } else {
                f.delete();
            }
        }
        if (file != null) {// 删除最外层
            file.delete();
        }
    }
}
